import MD5JS from '../utils/md5.js';
import axios from 'axios';
import store from '../store';
// export function getsj(qianm) {
//     store.dispatch('toggleAPIURL', 'development')
//     let key = store.getters.sidebar.apiKey;
//     let apiUrl = store.getters.sidebar.Url;
//     let dirPart = store.getters.sidebar.dirPart
//     let otherJsp = store.getters.sidebar.otherJsp
//     let signParam = qianm;
//     let signMD5 = MD5JS.hexMD5(signParam + "&key=" + key);
//     let Param = signParam + "&sign=" + signMD5;
//     let Url = apiUrl + dirPart + otherJsp
//     console.log(Url)
//     return new Promise((resolve, reject) => {
//         axios.get(Url + Param)
//         .then(res=>{
//             resolve(res)
//         })
//         .catch(err=>{
//             reject(err)
//         })
//     })
// }
// export function getsjcz(qianm) {
//     store.dispatch('toggleAPIURL', 'development')
//     let key = store.getters.sidebar.apiKey;
//     let apiUrl = store.getters.sidebar.Url;
//     let dirPart = store.getters.sidebar.dirPart
//     let mallJsp = store.getters.sidebar.mallJsp
//     let signParam = qianm;
//     let signMD5 = MD5JS.hexMD5(signParam + "&key=" + key);
//     let Param = signParam + "&sign=" + signMD5;
//     let Url = apiUrl + dirPart + mallJsp
//     console.log(Url)
//     return new Promise((resolve, reject) => {
//         axios.get(Url + Param)
//         .then(res=>{
//             resolve(res)
//         })
//         .catch(err=>{
//             reject(err)
//         })
//     })
// }
// export function getsjqw(qianm,qianw) {
//     store.dispatch('toggleAPIURL', 'development')
//     let key = store.getters.sidebar.apiKey;
//     let apiUrl = store.getters.sidebar.Url;
//     let dirPart = store.getters.sidebar.dirPart
//     let otherJsp = store.getters.sidebar.otherJsp
//     let signParam = qianm;
//     let signMD5 = MD5JS.hexMD5(signParam + "&key=" + key);
//     let Param = signParam + qianw + "&sign=" + signMD5;
//     let Url = apiUrl + dirPart + otherJsp
//     console.log(Url)
//     return new Promise((resolve, reject) => {
//         axios.get(Url + Param)
//         .then(res=>{
//             resolve(res)
//         })
//         .catch(err=>{
//             reject(err)
//         })
//     })
// }
// 数据获取函
export function getsj(aa, bb, cs , cc) {
    if (aa == 'aa') {
        store.dispatch('toggleAPIURL', 'development')
    } else {
        store.dispatch('toggleAPIURL', 'production')
    }
    if (bb == 'bb') {
        var otherJsp = store.getters.sidebar.otherJsp
    } else {
        var otherJsp = store.getters.sidebar.mallJsp
    }
    var key = store.getters.sidebar.apiKey;
    var apiUrl = store.getters.sidebar.Url;
    var dirPart = store.getters.sidebar.dirPart
    var signParam = cs;
    var signMD5 = MD5JS.hexMD5(signParam + "&key=" + key);
    if (!cc) {
        var Param = signParam + "&sign=" + signMD5;
    } else {
        var Param = signParam + cc + "&sign=" + signMD5;
    }
    let Url = apiUrl + dirPart + otherJsp
    console.log(Url)
    return new Promise((resolve, reject) => {
        axios.get(Url + Param)
            .then(res => {
                resolve(res)
            })
            .catch(err => {
                reject(err)
            })
    })
}
